﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

using modDatos;
using modInterface;

namespace modEscenario
{
    public static class SCescenario
    {
        /*
         * orden de Dibujado
           0- Fondo y escenario
         * 1- Elementos secundarios
         * 2- Actores Secundarios
         * 3- Actores
         * 4- Gui
         * 5- Alertas
         */
        private static Dictionary<string, IActor> ActorsOnStage = new Dictionary<string, IActor>();

        public static void pushActoOnStage ( string name, IActor actr )
        {
            if (ActorsOnStage.ContainsKey ( name ) == false)
            {
                ActorsOnStage.Add ( name, actr );
            }
            
        }

        public static void ClearActorOnStage()
        {
            ActorsOnStage.Clear();
        }

        public static void actuar ( ref SpriteBatch sprit )
        {
            sprit.Begin ( );
            foreach (KeyValuePair<string, IActor> item in ActorsOnStage)
            {
                item.Value.drawInEscenary ( ref sprit );
            }
            sprit.End ( );
        }

        //public static void ensayarConGamepad(Iespectador espectador)
        //{
        //    espectador.setearEstadosPorGamePad(GamePad.GetState);
        //}

        public static void ensayar (Microsoft.Xna.Framework.GameTime gameTime )
        {
            //en el mismo ensayo los actores informan de sus datos
            foreach (KeyValuePair<string, IActor> item in ActorsOnStage)
            {
                item.Value.ensayar(gameTime);
            }
        }
    }
}
